﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

@if (ParentDropdownState.IsHorizontal)
{
    <div @attributes="@AdditionalAttributes" class="@DropdownClassString" data-visible="@ParentDropdownState.DropdownVisibleString"
        @onmouseenter="@OnMouseEnterHandler" 
        @onmouseleave="@OnMouseLeaveHandler">
        @ChildContent
    </div>
}
else
{
    @if (ParentDropdownState.HasFloatingMenu)
    {
        <Floating AutoUpdate
            AutoHide ="false"
            Anchor ="@ParentDropdown?.Id"
            Visible ="@ParentDropdownState.DropdownVisible"
            Placement ="@ParentDropdownState.FloatingPlacement"
            ContainerId ="@($"{ParentDropdownState.Id}_container")">
            <CascadingValue Value="@ParentItem" IsFixed>
                <CascadingValue Value="@ParentItemState">
                    <CascadingValue Value="@ParentDropdown" IsFixed>
                        <CascadingValue Value="@ParentDropdownState">
                            <div class="@FloatingContainerClassString">
                                <div @attributes="@AdditionalAttributes" class="@FloatingClassString" data-visible="@ParentDropdownState.DropdownVisibleString"
                                    @ref="@Wrapper.Ref" 
                                    @onmouseenter="@OnMouseEnterHandler">
                                    <div class="navbar-track">
                                        <div class="navbar-thumb"></div>
                                    </div>
                                    @ChildContent
                                </div>
                            </div>
                        </CascadingValue>
                    </CascadingValue>
                </CascadingValue>
            </CascadingValue>
        </Floating>
    }

    @if(ParentDropdownState.HasPopoutMenu)
    {
        <div class="@DropdownContainerClassString">
            <div @attributes="@AdditionalAttributes" class="@DropdownClassString" data-visible="@ParentDropdownState.DropdownVisibleString"
                @onmouseenter="@OnMouseEnterHandler"
                @onmouseleave="@OnMouseLeaveHandler">
                @ChildContent
            </div>
        </div>
    }
}
